import unittest
import time

from selenium.webdriver.common.by import By

from common.base import get_driver
from page.shopping_page import ShoppingPage


class Shoppping_Modify_TestCase(unittest.TestCase):
    def test_shopping_modify(self):
        # TODO 操作流程
        # 创建driver
        driver = get_driver()
        driver.get("http://localhost:8080/ecshop/flow.php")
        driver.maximize_window()
        # 创建页面对象
        self.shopping = ShoppingPage(driver)
        self.shopping.add_goods()
        self.shopping.click_modify_goods(5)
        time.sleep(1)

        # TODO 断言
        """
        预期 和 实际结果 的比对
        """
        goods_count = self.shopping.get_text((By.XPATH, "//input[@value='5']"))
        actual_goods_count = self.shopping.get_text((By.XPATH, "//input[@value='5']"))
        self.assertEqual(goods_count, actual_goods_count, msg="查看到的商品数量显示错误")


if __name__ == '__main__':
    unittest.main(verbosity=2)